package com.inifitness.admin.core.system.converter;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inifitness.admin.core.system.model.bo.UserBO;
import com.inifitness.admin.core.system.model.entity.SysUser;
import com.inifitness.admin.core.system.model.form.UserForm;
import com.inifitness.admin.core.system.model.vo.UserImportVO;
import com.inifitness.admin.core.system.model.vo.UserInfoVO;
import com.inifitness.admin.core.system.model.vo.UserPageVO;

import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 用户对象转换器
 *
 * @author sunjinfeng
 * @since 2024/04/18 11:00:00
 */
@Mapper(componentModel = "spring")
public interface UserConverter {

  @Mapping(target = "genderLabel", expression = "java(com.inifitness.common.basic.BaseEnum.getLabelByValue(com.inifitness.common.enums.GenderEnum.class,bo.getGender()))")
  UserPageVO bo2PageVo(UserBO bo);

  Page<UserPageVO> bo2PageVo(Page<UserBO> bo);

  UserForm entity2Form(SysUser entity);

  @InheritInverseConfiguration(name = "entity2Form")
  SysUser form2Entity(UserForm entity);

  @Mapping(target = "userId", source = "id")
  UserInfoVO toUserInfoVo(SysUser entity);

  SysUser importVo2Entity(UserImportVO vo);

}
